//
//  CCVSCustomTypes.h
//  CollectionViewTest
//
//  Created by Pasirstein, David B on 4/23/13.
//  Copyright (c) 2013 Pasirstein, David B. All rights reserved.
//

#import <Foundation/Foundation.h>

///////////////////////////////////////////
@protocol CCVSCustomDataType <NSObject>
@required

//The next line must be set to the impl for the CCVSCustomViewType
//the string will by used in "=[NSClassFromString(xxxx) alloc] initWithData...]"
@property (nonatomic,strong) NSString * customViewType;
@property (nonatomic) BOOL isExpanded; //used for tracking whether the view has been expanded (aka "More....")

@end
///////////////////////////////////////////
@protocol CCVSCustomViewType <NSObject>
@required

@property (nonatomic,strong) id<CCVSCustomDataType> data; //should be set by data in init

-(BOOL)isExpandable; //will return if the view should support dyanamic resizing

//should return the frame size with width and height populated
+(CGSize)calcViewHeight:(CGFloat)viewWidth fromObject:(id<CCVSCustomDataType>)data;

//initialize the object...primary way it will be init'ed
-(id)initWithData:(id<CCVSCustomDataType>)data withFrame:(CGRect)frame viewController:(UIViewController*)vc;

//should build view to be displayed (would likely return self)
-(UIView*)buildView;

-(BOOL)willSegueOnEvent;//true/false if the view will require a segue

@optional
//if true above this should return the name of the segue
//if this was requested as a result of a gesture event
//the gesture will be provided as well
-(NSString*)nameOfSegue:(UIGestureRecognizer*)gesture;

@end

////////////////////////////////////////////
@protocol CCVSCustomURLViewType <CCVSCustomViewType>
@required
@property (nonatomic,strong) NSString * title;
@property (nonatomic,strong) NSURL * destination;

@end
////////////////////////////////////////////
@protocol CCVSCustomImageViewType <CCVSCustomViewType>

//Ideally, the implementing class would extend UIImageView
//and then point _iview to self and return that in the getter
@property (nonatomic,weak) UIImageView * iview;

//URL to large image, this could be nil, in which case
//the iview.image would be used
@property (nonatomic,strong) NSURL * largeImageURL;

@end

////////////////////////////////////////////
////////////////////////////////////////////
//The following protocol is listed for reference in impl
//of the above classes.  this protocol should only be
//implemented in the view controller
@protocol CCVSCustomViewDelegate
//This delegate should be implemented in the view controller
//the will receive and handle gesture events
- (void)handleTapGestureForURLViewType:(UITapGestureRecognizer *) gesture;
- (void)handleTapGestureForImageViewType:(UITapGestureRecognizer *) gesture;

//For the segue view controller to receive the data, it must have a property
//called ccvsCustomData (or a selector called setCcvsCustomData:)
- (void)segueToVCWith:(id<CCVSCustomDataType>)data segueName:(NSString*)destSegue;

//this will toggle the isExpanded variable in the custom data type object
//and then refresh the view to support resize events
-(void)toggleExpantionAndRefreshView:(id)sender forDataType:(id<CCVSCustomDataType>)data;

//refresh the collection view to handle resize events
-(void)refreshCollectionView:(id)sender;


@end

